package lock2;

public class MyLock2 {
	private boolean lock = false;
	
	public synchronized void lock() {
		if(lock) {
			try {
				wait();
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
		lock = true;
	}
	
	public synchronized void unLock() {
		lock = false;
		notifyAll();
	}

}
